<?php
/**
 * @version 0.8.3 2010-10-07
 * @package Joomla
 * @subpackage LeagueResults
 * @copyright (C)  2008, 2009, 2010 Henryk Drozd
 * @license GNU/GPL, see LICENSE.php
 * LeagueResults is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License 2
 * as published by the Free Software Foundation.

 * LeagueResults is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die('Restricted access');
?>

<div class="componentheading">
<?php echo JText::_( 'TABLE OF RESULTS' ); 
?>
</div>

<a href="<? echo $this->backlink; ?>">
	<?php echo JText::_( '' ); ?>
</a><br/><br/>
<table class="seasonheading">
<tr><td><? echo $this->list[0]->longname.' '.$this->list[0]->year; ?></td></tr>
<tr><td><? echo $this->list[0]->formattedtdate;?></td></tr></table>

<table class="resultstable" >
<tr>
	<th width="10%"><?php echo JText::_( 'RT POSITION' ); ?></th>
	<th><?php echo JText::_( 'RT TEAM' ); ?></th>
	<th><?php echo JText::_( 'RT MATCHES' ); ?></th>
	<th><?php echo JText::_( 'RT WINS' ); ?></th>
	<th><?php echo JText::_( 'RT DEFEATS' ); ?></th>
	<th><?php echo JText::_( 'RT POINTS' ); ?></th>
	<th><?php echo JText::_( 'RT SCORE' ); ?></th>
	<th><?php echo JText::_( 'RT DIFF' ); ?></th>

	
</tr>
<?php 
$native_team = JRequest::getVar('native_team');


foreach ($this->list as $l):
	if ($native_team == $l->team_id)
		echo '<tr class="native_team">';
	else
		echo '<tr>';

// distinct color or nothing
	
	if (JRequest::getVar('zones_ondisplay') == 'yes'){
		if ($l->position <= $this->tablemap['promoted'])
			$td_class = ' class="promoted" '.$nc;
		elseif ($l->position <= $this->tablemap['semipromoted'])
			$td_class = ' class="semipromoted"';
		elseif ($l->position >= $this->tablemap['semirelegated'] and 
				$l->position < $this->tablemap['relegated'])
			$td_class = ' class="semirelegated"';
		elseif ($l->position >= $this->tablemap['relegated'])
			$td_class = ' class="relegated"';
		else
			$td_class = $nc;
	}
	else
			$td_class = '';
	
?>
	<td <?php echo $td_class;?>><?php echo $l->position; ?></td>
	<td <?php echo $td_class;?>>
		<?php if (JRequest::getVar('badges_ondisplay') == 'default'?
					$this->settings->frontend_images:
					JRequest::getVar('badges_ondisplay') == 'yes') {?>
					<img src="<?php echo $this->settings->tbadge_folder.$l->tbadge; ?>" />
				<?php }?>
		
			<?php switch (JRequest::getVar('links_ondisplay')){ 
				case 'none':
				default:
					echo $l->tablename;
					break;
				case 'club':
			?>
			    	<a href="<?php echo $l->clublink; ?>">
		        	<?php echo $l->tablename; ?></a>
			<?php 
					break;
				case 'team':
			?>
			    	<a href="<?php echo $l->link; ?>">
		        	<?php echo $l->tablename; ?></a>
			<?php 
					break;
				case 'website':
			?>
			    	<a href="<?php echo $l->url; ?>">
		        	<?php echo $l->tablename; ?></a>
			<?php
					break;
				}
			?>
	</td>
	<td <?php echo $td_class;?>><?php echo $l->matches; ?></td>
	<td <?php echo $td_class;?>><?php echo $l->wins; ?></td>
	<td <?php echo $td_class;?>><?php echo $l->defeats; ?></td>
	<td <?php echo $td_class;?>><?php echo sprintf($l->pointsformat, $l->points); ?></td>
	<td <?php echo $td_class;?>><?php echo $l->scoreplus.':'.$l->scoreminus; ?></td>
	<td <?php echo $td_class;?>><?php echo ($l->scoreplus-$l->scoreminus); ?></td>

</tr>
<?php endforeach; ?>

</table>

